package cn.gok.day3;

/**
 * @ClassName Test
 * @Description TODO
 * @Author HP
 * @Date 9:49 2022/7/6
 * @Version 1.0
 **/
public class Test {
    static class Pento{
        public void say(){
            System.out.println("动物发出叫声！");
        };
    }
public static class oscar{

        Pento pento=new Pento(){
            @Override
            public void say() {
                System.out.println("恶龙咆哮");
            }
        };
        public interface Job{
            public void toJob();
            public void toSay();
        }
        Job job=new Job() {
            @Override
            public void toJob() {
                System.out.println("实现接口匿名内部类");
            }

            @Override
            public void toSay() {
                System.out.println("实现接口匿名内部类");

            }
        };

}
    public Test() {
    }
    public static class Teacher{
        public int teach(){
            System.out.print("老师教书： ");
            return 10;
        }


    }

    public static void main(String[] args) {
//        Teacher teacher1=new Teacher(){
//            @Override
//            public int teach() {
//                return 20;
//            }
//        };
//        Teacher teacher2=new Teacher(){
//            @Override
//            public int teach() {
//                return 30;
//            }
//        };
//        System.out.println("老师教书： "+teacher1.teach()+"小时哦");
//        System.out.println("老师教书： "+teacher2.teach()+"小时哦");
M m=new M(){
    @Override
    public void run() {
        System.out.println("匿名内部类在跑");
    }

    @Override
    public void say() {
        super.say();
    }
};
MC mc=new MC();
mc.run();
    }
//    关于abstract关键字的使用
    abstract static class M{
        public void say(){
            System.out.println("我在说话");
        };
        public abstract void run();
}
static class MC extends M{

    @Override
    public void run() {
        System.out.println("我是M的子类，我在跑");
    }
}
}
